{% extends "admin/base_site.html" %}
{% load i18n static %}

{% block title %}数据分析 | {{ site_title|default:_('Django site admin') }}{% endblock %}

{% block content %}
<div class="analytics-container">
    <h1 style="color: #417690; margin-bottom: 30px;">📈 数据分析中心</h1>

    <!-- 分析控制面板 -->
    <div style="background: white; padding: 25px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin-bottom: 30px;">
        <h3 style="color: #417690; margin-bottom: 20px;">🎛️ 分析控制面板</h3>
        <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px;">
            <div>
                <label style="display: block; margin-bottom: 5px; font-weight: bold;">时间范围:</label>
                <select style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
                    <option>最近7天</option>
                    <option>最近30天</option>
                    <option>最近3个月</option>
                    <option>最近1年</option>
                </select>
            </div>
            <div>
                <label style="display: block; margin-bottom: 5px; font-weight: bold;">分析维度:</label>
                <select style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
                    <option>用户行为</option>
                    <option>销售数据</option>
                    <option>产品表现</option>
                    <option>地域分布</option>
                </select>
            </div>
            <div style="display: flex; align-items: end;">
                <button style="padding: 8px 20px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer;">
                    🔍 开始分析
                </button>
            </div>
        </div>
    </div>

    <!-- 关键指标 -->
    <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px;">
        <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; border-radius: 10px; text-align: center;">
            <h4 style="margin: 0 0 10px 0;">转化率</h4>
            <h2 style="margin: 0; font-size: 2.5em;">12.3%</h2>
            <p style="margin: 5px 0 0 0; opacity: 0.9;">↑ 比上月提升 2.1%</p>
        </div>

        <div style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; padding: 20px; border-radius: 10px; text-align: center;">
            <h4 style="margin: 0 0 10px 0;">客单价</h4>
            <h2 style="margin: 0; font-size: 2.5em;">¥368</h2>
            <p style="margin: 5px 0 0 0; opacity: 0.9;">↓ 比上月下降 5.2%</p>
        </div>

        <div style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: white; padding: 20px; border-radius: 10px; text-align: center;">
            <h4 style="margin: 0 0 10px 0;">活跃用户</h4>
            <h2 style="margin: 0; font-size: 2.5em;">1,234</h2>
            <p style="margin: 5px 0 0 0; opacity: 0.9;">↑ 比上月增长 8.7%</p>
        </div>

        <div style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); color: white; padding: 20px; border-radius: 10px; text-align: center;">
            <h4 style="margin: 0 0 10px 0;">复购率</h4>
            <h2 style="margin: 0; font-size: 2.5em;">35.6%</h2>
            <p style="margin: 5px 0 0 0; opacity: 0.9;">↑ 比上月提升 1.3%</p>
        </div>
    </div>

    <!-- 分析图表区域 -->
    <div style="display: grid; grid-template-columns: 2fr 1fr; gap: 30px; margin-bottom: 30px;">
        <!-- 主图表 -->
        <div style="background: white; padding: 25px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
            <h3 style="color: #417690; margin-bottom: 20px;">📊 销售趋势分析</h3>
            <div style="text-align: center; padding: 80px 20px; color: #6c757d; background: #f8f9fa; border-radius: 8px; border: 2px dashed #dee2e6;">
                <i style="font-size: 64px; margin-bottom: 20px;">📈</i>
                <h4 style="margin-bottom: 15px;">销售趋势图</h4>
                <p style="margin: 0; font-size: 16px;">这里可以显示销售数据的时间趋势</p>
                <p style="margin: 5px 0 0 0; color: #adb5bd;">集成图表库后可显示实际数据</p>
            </div>
        </div>

        <!-- 侧边统计 -->
        <div style="background: white; padding: 25px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
            <h3 style="color: #417690; margin-bottom: 20px;">🎯 热门产品</h3>
            <div style="space-y: 15px;">
                <div style="display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee;">
                    <div>
                        <div style="font-weight: bold;">iPhone 15 Pro</div>
                        <div style="font-size: 12px; color: #6c757d;">销量: 128台</div>
                    </div>
                    <div style="background: #28a745; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">
                        +15%
                    </div>
                </div>

                <div style="display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee;">
                    <div>
                        <div style="font-weight: bold;">华为Mate 60</div>
                        <div style="font-size: 12px; color: #6c757d;">销量: 95台</div>
                    </div>
                    <div style="background: #ffc107; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">
                        +8%
                    </div>
                </div>

                <div style="display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee;">
                    <div>
                        <div style="font-weight: bold;">小米14 Ultra</div>
                        <div style="font-size: 12px; color: #6c757d;">销量: 76台</div>
                    </div>
                    <div style="background: #dc3545; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">
                        -3%
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 用户行为分析 -->
    <div style="background: white; padding: 25px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin-bottom: 30px;">
        <h3 style="color: #417690; margin-bottom: 20px;">👥 用户行为分析</h3>
        <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px;">
            <!-- 用户来源 -->
            <div>
                <h4 style="margin-bottom: 15px; color: #495057;">用户来源分布</h4>
                <div style="text-align: center; padding: 40px; background: #f8f9fa; border-radius: 8px;">
                    <i style="font-size: 48px; margin-bottom: 15px;">🥧</i>
                    <p style="margin: 0;">饼状图显示用户来源</p>
                </div>
            </div>

            <!-- 页面浏览 -->
            <div>
                <h4 style="margin-bottom: 15px; color: #495057;">页面浏览热力图</h4>
                <div style="text-align: center; padding: 40px; background: #f8f9fa; border-radius: 8px;">
                    <i style="font-size: 48px; margin-bottom: 15px;">🔥</i>
                    <p style="margin: 0;">热力图显示页面访问情况</p>
                </div>
            </div>
        </div>
    </div>

    <!-- 建议和洞察 -->
    <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; border-radius: 10px; margin-bottom: 30px;">
        <h3 style="margin-bottom: 20px;">💡 智能建议</h3>
        <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px;">
            <div style="background: rgba(255,255,255,0.1); padding: 20px; border-radius: 8px;">
                <h5 style="margin-bottom: 10px;">📈 销售优化</h5>
                <p style="margin: 0; opacity: 0.9;">建议增加iPhone 15 Pro的库存，该产品销量持续上升</p>
            </div>

            <div style="background: rgba(255,255,255,0.1); padding: 20px; border-radius: 8px;">
                <h5 style="margin-bottom: 10px;">👥 用户增长</h5>
                <p style="margin: 0; opacity: 0.9;">VIP用户转化率较高，建议加强VIP营销活动</p>
            </div>

            <div style="background: rgba(255,255,255,0.1); padding: 20px; border-radius: 8px;">
                <h5 style="margin-bottom: 10px;">🛒 订单处理</h5>
                <p style="margin: 0; opacity: 0.9;">待处理订单较多，建议增加客服人员</p>
            </div>
        </div>
    </div>

    <!-- 操作按钮 -->
    <div style="text-align: center;">
        <a href="{% url 'admin:index' %}" style="display: inline-block; padding: 12px 24px; background: #6c757d; color: white; text-decoration: none; border-radius: 6px; margin: 0 10px;">
            ← 返回主页
        </a>
        <a href="{% url 'super_admin:reports' %}" style="display: inline-block; padding: 12px 24px; background: #17a2b8; color: white; text-decoration: none; border-radius: 6px; margin: 0 10px;">
            查看报表
        </a>
        <button style="padding: 12px 24px; background: #28a745; color: white; border: none; border-radius: 6px; margin: 0 10px; cursor: pointer;">
            📊 导出报告
        </button>
    </div>
</div>
{% endblock %}
